package cn.shadow.utils;

public class NameHelper {
    public static final int NAME_MAX_LENGTH = 14;
    private static final int USER_NAME_MIN_LENGTH = 3; // 包含
    private static final int USER_NAME_MAX_LENGTH = 16;
    private static final int NAME_MIN_LENGTH = 3; // 包含
    private static final char[] symbols = new char[36];

    static {
        for (int idx = 0; idx < 10; ++idx) {
            symbols[idx] = (char) ('0' + idx);
        }
        for (int idx = 10; idx < 36; ++idx) {
            symbols[idx] = (char) ('a' + idx - 10);
        }
    }

    public static boolean isValidUserName(String s) {
        for (int j = s.length(); --j >= 0; ) {
            char c = s.charAt(j);
            if ((c < '0' || c > '9') && (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && c != '_') {
                return false;
            }
        }

        return true;
    }



    public static boolean isValidPlayerName(String s) {
        for (int j = s.length(); --j >= 0; ) {
            char c = s.charAt(j);

            if (c <= ' ' || c == '\ue779') { // windows下显示为空格
                return false;
            }

            if (c == '[' || c == ']' || c == '.' || c == '|' || c == ',' || c == ';' || c == '\\' ||
                    c == '\'' || c == '"') {
                return false;
            }
        }

        return true;
    }

}
